
namespace Behemoth.SharePoint.Security {

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.SharePoint;

    using Behemoth.SharePoint.Logging;

    public class Delegation {

      private static BehemothLoggingService _log = new BehemothLoggingService();
      public static BehemothLoggingService Log {
        get { return _log; }
      }

      #region IDelegation Members
      
        /// <summary>
        /// Runs the specified code delegate with elevated priviliges and logs the username of the actual user running the code.
        /// </summary>
        /// <param name="web">Reference to the current web</param>
        /// <param name="codeDelegate">Code to run.</param>
        public static void RunWithElevatedPriviliges(SPWeb web, SPSecurity.CodeToRunElevated codeDelegate) {
          _log.Write(string.Format("Running Elevated {0} at on behalf of {1}.", web.Url, web.CurrentUser.LoginName));
          SPSecurity.RunWithElevatedPrivileges(
              
              codeDelegate
              
          );
          // TODO can we have a version of this that recreates the web objects if we need to
        }

      #endregion

    } // class
} // namespace